<?php
class tinhtoan{	
	private $a;
	private $b;
	public $result;

	public function tinhtoan($a, $b){
		$this->a = $a;
		$this->b = $b;
	}		
	public function cong(){
		$this->result = $this->a + $this->b;		
	}
	public function tru(){
		$this->result = $this->a - $this->b;
	}
	public function nhan(){
		$this->result = $this->a * $this->b;
	}
	public function chia(){    
		$this->result = $this->a / $this->b;
	}	
	
	public function pheptoan($method){	
		switch($method)
		{
			case "cong":
				$this->cong();
				break;
			case "tru":
				$this->tru();
				break;
			case "nhan":
				$this->nhan();
				break;
			case "chia":
				$this->chia();
				break;							
			default:
				$this->result = "Không đúng phương thức tính toán";
				break;        
		}    
	}
}
?>